/**
 * Setvor project
 */
package setvor.yeild;

/**
 * @author julatec
 *
 */
public abstract class ValueBasedIterator<T> extends YeildIterator<T> {
	
	private T currentValue;
	
	private boolean isFirst;
	
	public ValueBasedIterator(T initialValue){
		super();
		isFirst = true;
		this.currentValue = initialValue;
	}
	
	protected abstract T next(T value);
	
	public T next(){
		if(isFirst){
			isFirst = false;
			return currentValue;
		}
		return currentValue = next(currentValue); 
	}

}
